package com.dhms.vostok1.data.spot_patrol

import com.squareup.moshi.Json

data class DeviceCategoryData(
    @Json(name = "ct_id")
    val ctID: Int,
    @Json(name = "ct_name")
    val ctName: String,
    @Json(name = "ct_path")
    val ctPath: String,
    @Json(name = "ct_sort")
    val ctSort: Int?
) {
    //是否根节点
    val isRootNode: Boolean
        get() {
            if (nodes.count() == 1 && nodes[0].toInt() == ctID)
                return true
            return false
        }

    val rootNode: Int
        get() {
            if (nodes.isNotEmpty()) {
                return nodes[0].toInt()
            }
            return -1
        }

    val nodes: List<String>
        get() {
            return ctPath.removePrefix("/").removeSuffix("/").split("/")
        }
}
